﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace XWG.JWBST.JWBSTManagementApp.Application
{
    public partial class TbBstLetter : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            List<JWBSTEntity.TbBstLetter> letlist = new List<JWBSTEntity.TbBstLetter>();
            DataTable dt = new DataTable();
            string id = HttpContext.Current.Request.Params["id"].ToString();
            string phone = HttpContext.Current.Request.Params["phone"].ToString();
            string psd = HttpContext.Current.Request.Params["psd"].ToString();
            dt = XWG.JWBST.JWBSTBLL.LetterBLL.GetLikeInfo(DES.Encode(phone), psd, id);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                JWBSTEntity.TbBstLetter lett = new JWBSTEntity.TbBstLetter();
                if (dt.Rows[i]["tabletype"].ToString() == "1")
                {
                    lett.Tabletype = "诉求直通";
                }
                else if (dt.Rows[i]["tabletype"].ToString() == "2")
                {
                    lett.Tabletype = "局长信箱";
                }
                else
                {
                    lett.Tabletype = "网上信访";
                }
                if (dt.Rows[i]["content"].ToString().Length > 21)
                {
                    lett.Content = dt.Rows[i]["content"].ToString().Substring(0, 20) + "...";
                }
                else
                {
                    lett.Content = dt.Rows[i]["content"].ToString();
                }

                lett.Createdate = dt.Rows[i]["createdate"].ToString();
                if (dt.Rows[i]["zb_bljg"].ToString().Length > 16)
                {
                    lett.BLJG = dt.Rows[i]["zb_bljg"].ToString().Substring(0, 15) + "...";
                }
                else
                {
                    lett.BLJG = dt.Rows[i]["zb_bljg"].ToString();
                }
                lett.BLRQ = dt.Rows[i]["zb_blrq"].ToString();
                letlist.Add(lett);
            }
            this.GridView2.DataSource = letlist;
            this.GridView2.DataBind();
        }
    }
}